﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.UI
{
    /// <summary>
    /// 区域的位置信息，在场景中保存第一级区域的位置信息
    /// </summary>
    public class ChildrenPosInfo
    {
        private List<ChildPos> _pos = new List<ChildPos>();

        public int Count
        {
            get
            {
                return _pos.Count;
            }
        }

        public ChildPos this[int index]
        {
            get
            {
                return _pos[index];
            }
        }

        public ChildPos Get(string name)
        {
            for (int index = 0; index < _pos.Count; index++)
            {
                if (_pos[index].Name == name)
                {
                    return _pos[index];
                }
            }
            return null;
        }

        public void Set(string name, double left)
        {
            bool isExist = false;
            for (int index = 0; index < _pos.Count; index++)
            {
                if (_pos[index].Name == name)
                {
                    _pos[index].Left = left;
                    isExist = true;
                }
            }

            if (!isExist)
            {
                ChildPos pos = new ChildPos();
                pos.Name = name;
                pos.Left = left;
                _pos.Add(pos);
            }
        }
    }

    public class ChildPos
    {
        public string Name { get; set; }
        public double Left { get; set; }
    }
}
